/*
package com.example.clickhouse.demo.config;

import com.clickhouse.jdbc.ClickHouseDataSource;
import com.zaxxer.hikari.HikariConfig;
import com.zaxxer.hikari.HikariDataSource;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Properties;

@Configuration
public class DataSourceConfig {

    @Bean
    public DataSource dataSource() throws SQLException {
        HikariConfig poolConfig = new HikariConfig();
        poolConfig.setConnectionTimeout(5000L);
        poolConfig.setMaximumPoolSize(200);
        poolConfig.setMaxLifetime(300_000L);
        Properties properties = new Properties();
        properties.setProperty("compress", "false");
        poolConfig.setDataSource(new ClickHouseDataSource("jdbc:clickhouse://localhost:8123/default", properties));
        HikariDataSource ds = new HikariDataSource(poolConfig);

        try (Connection conn = ds.getConnection()) {
            Statement s = conn.createStatement();
            ResultSet rs = s.executeQuery("select * from test");
            System.out.println("======================");
            System.out.println(rs.next());
            System.out.println(rs.getInt(1));
            System.out.println("======================");
        }
        return ds;
    }

}
*/
